package com.famdoc.Controller;

import com.famdoc.Pojo.dto.PatientArchiveForm;
import com.famdoc.Pojo.dto.Result;
import com.famdoc.Pojo.entity.Patient;
import com.famdoc.Service.ArchiveService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 档案类
 */
@RestController
public class ArchiveController {
    @Resource
    private ArchiveService archiveService;

    /**
     * 建档
     * @param patientArchiveForm
     * @return
     */
    @PostMapping("/filing")
    public Result Filing(@Valid @RequestBody PatientArchiveForm patientArchiveForm){
        return archiveService.Filing(patientArchiveForm);
    }

    /**
     * 分页查询个人档案（包括个人档案列表）
     * @param page
     * @param pageSize
     * @param name
     * @param idNumber
     * @param phoneNumber
     * @return
     */
    @GetMapping("/queryFile")
    public Result QueryFile(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize,
                            @RequestParam("name") String name, @RequestParam("idNumber") String idNumber,
                            @RequestParam("phoneNumber") String phoneNumber){
        return archiveService.QueryFile(page,pageSize,name,idNumber,phoneNumber);
    }

    /**
     * 修改个人档案
     * @param patient
     * @return
     */
    @PostMapping("/modifyFile")
    public Result modifyFile(@RequestBody Patient patient){
        return archiveService.modifyFile(patient);
    }
}
